<template>
  <el-drawer
    :title="translate('zxkxq')"
    size="60%"
    :visible.sync="isShowDrawer"
    @close="closeDrawer"
  >
    <div class="detail_header">
      <div class="sp_bew">
        <div class="left">
          <el-image v-if="detail.allPath" :src="detail.allPath" class="img" />
          <div class="title_wrap">
            <div>
              <span class="title">{{ detail.name }}</span>
              <span class="status">{{
                detail.status === "1" ? translate("yqy") : translate("jy")
              }}</span>
            </div>
            <div class="placeholder9 mt10">
              {{ translate("zfsl") }}：{{
                detail.circulationAll || translate("limitNot")
              }}
            </div>
          </div>
        </div>
        <div class="right">
          <div class="item">
            <div class="key">{{ translate("zfxsl") }}</div>
            <div class="value">
              {{ detail.circulationAll || translate("limitNot") }}
            </div>
          </div>
          <div class="item">
            <div class="key">{{ translate("saleNumEd") }}</div>
            <div class="value">{{ detail.sellNum }}</div>
          </div>
          <div class="item">
            <div class="key">{{ translate("residueNum") }}</div>
            <div class="value">
              {{ detail.remainNum || translate("limitNot") }}
            </div>
            <!-- <div v-else class="value">{{ detail.surplusDay || this.translate('limitNot') }}</div> -->
          </div>
        </div>
      </div>
      <div class="createTime_wrap">
        <span
          class="item"
        >{{ translate("createTime") }}：{{ detail.createTime }}</span>
        <span
          class="item"
        >{{ translate("creator") }}：{{ detail.creator }}</span>
        <span
          class="item"
        >{{ translate("updateTimeLast") }}：{{ detail.editTime }}</span>
        <span
          class="item"
        >{{ translate("updateTor") }}：{{ detail.editor }}</span>
      </div>
    </div>
    <div class="separate" />
    <div class="property-title">{{ translate("jbxx") }}</div>
    <div class="line">
      <div class="key">{{ translate("specialCardName") }}：</div>
      <div class="value">{{ detail.name }}</div>
    </div>
    <div class="line">
      <div class="key">{{ translate("salesPrive") }}：</div>
      <div class="value">{{ detail.price || 0 }}{{ translate("rmb") }}</div>
    </div>
    <div class="line">
      <div class="key">{{ translate("bjyxq") }}：</div>
      <div class="value">
        {{
          detail.validTimeType == "1"
            ? translate("cqyx")
            : detail.validTime + translate("tnyx")
        }}
      </div>
    </div>
    <div class="line">
      <div class="key">{{ translate("sgzj") }}：</div>
      <div class="value">
        {{
          detail.firstBuyIsGive == "0"
            ? translate("buzengsong")
            : detail.firstBuyGiveMoney +
              translate("yuanyxq") +
              detail.firstGiveMoneyValidTime +
              translate("days")
        }}
      </div>
    </div>
    <div class="line">
      <div class="key">{{ translate("fgzj") }}：</div>
      <div class="value">
        {{
          detail.repetitionBuyIsGive == "0"
            ? translate("buzengsong")
            : detail.repetitionBuyGiveMoney +
              translate("yuanyxq") +
              detail.repetitionGiveMoneyValidTime +
              translate("days")
        }}
      </div>
    </div>
    <div class="line">
      <div class="key">{{ translate("zxkbenjin") }}：</div>
      <div class="value">{{ detail.cardPrice }}</div>
    </div>
    <div class="line">
      <div class="key">{{ translate("smsj") }}：</div>
      <div class="value">
        {{
          detail.sellTimeType == "0"
            ? translate("cqsm")
            : detail.sellTimeStartString + " ~ " + detail.sellTimeEndString
        }}
      </div>
    </div>
    <div class="userInfo">
      <div class="key">{{ translate("useDesc") }}：</div>
      <div class="value" v-html="detail.useInfo" />
    </div>

    <div class="property-title mt20">{{ translate("applyRules") }}</div>
    <div class="line">
      <div class="key">{{ translate("zfxsl") }}：</div>
      <div class="value">
        {{ detail.circulationAll || translate("limitNot") }}
      </div>
    </div>
    <div class="line">
      <div class="key">{{ translate("zhuanzengFlag") }}：</div>
      <div class="value">
        {{ detail.type == "1" ? translate("noSupport") : translate("support") }}
      </div>
    </div>
    <div class="line">
      <div class="key">{{ translate("applyVenue") }}：</div>
      <div class="value">{{ detail.useVenue }}</div>
    </div>
    <div class="df">
      <div class="key">{{ translate("xfqy") }}：</div>
      <el-table
        ref="table"
        :data="detail.discountItemInfo"
        border
        fit
        :header-row-class-name="'table-header'"
        class="doumee-element-table"
      >
        <el-table-column
          align="center"
          :label="translate('xfcj')"
          min-width="120"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.orderTypeName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          :label="translate('discount')"
          min-width="80"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.discountInfo }}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          :label="translate('applyFanwei')"
          min-width="120"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.useInfo || translate("all") }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </el-drawer>
</template>

<script>
import {
  SpeailCardDetail
} from '@/api'
export default {
  name: 'ComboAdd',
  data() {
    return {
      isShowDrawer: false,
      detail: {},
      vipTypes: [],
      channels: {
        '1': this.translate('xcx'),
        '2': this.translate('cgpcd')
      }
    }
  },
  methods: {
    closeDrawer() {
      this.isShowDrawer = false
      this.$emit('close')
    },
    getDetail(id) {
      SpeailCardDetail({ param: { id }}).then(res => {
        this.detail = { ...res.record }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import "@/styles/variables.scss";

.line {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  font-size: 14px;
  // padding-left: 16px;
  .key {
    color: #666666;
    // width: 100px;
    // text-align: right;
  }
  .value {
    color: #222222;
    flex: 1;
  }
}
.userInfo {
  display: flex;
  .key {
    // width: 100px;
    // text-align: right;
  }
  .value {
    ::v-deep p {
      margin: 0;
    }
    flex: 1;
    overflow: auto;
  }
}
.discount_wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding-left: 34px;
  font-size: 14px;
  .key {
    width: 90px;
  }
  .discount {
    width: 33.33%;
    margin-bottom: 20px;
  }
}
.detail_header {
  font-size: 14px;
  .sp_bew {
    display: flex;
    justify-content: space-between;
    .left {
      display: flex;
      .img {
        width: 120px;
        margin-right: 20px;
      }
      .title {
        font-size: 18px;
        font-weight: 600;
        color: #222222;
      }
      .status {
        border-radius: 2px;
        border: 1px solid $primaryColor;
        color: $primaryColor;
        margin-left: 10px;
      }
    }
    .right {
      display: flex;
      background-color: #f4f7fc;
      border-radius: 2px;
      .item {
        padding: 14px 20px;
        .key {
          font-size: 12px;
          color: #666666;
        }
        .value {
          margin-top: 8px;
          color: #222222;
          font-weight: 600;
        }
      }
    }
  }
  .createTime_wrap {
    display: flex;
    margin: 16px 0;
    .item {
      margin-left: 30px;
      color: #999999;
      &:first-of-type {
        margin-left: 0;
      }
    }
  }
}
.separate {
  height: 1px;
  margin: 20px -20px;
  padding: 0 20px;
  background-color: #dfe2e8;
}
.tip {
  font-size: 14px;
  line-height: 1.5;
  color: #333;
}

.device-uploader {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  cursor: pointer;
  border: 1px dashed #ccc;
  border-radius: 8px;
  transition: all 0.3s;
  margin-right: 20px;

  &:hover {
    border-color: $menuActive;

    .uploader-icon {
      color: $menuActive;
    }
  }

  ::v-deep .el-upload {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;

    .file {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      background-size: contain;
      background-position: center;
      background-repeat: no-repeat;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;

      .delete {
        background-color: rgba(0, 0, 0, 0.5);
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        display: none;
        align-items: center;
        justify-content: center;

        .icon {
          color: #fff;
        }
      }

      &:hover {
        .delete {
          display: flex;
        }
      }
    }
  }

  .uploader-icon {
    color: #aaaaaa;
    font-size: 22px;
    transition: all 0.3s;
  }
}
.count-style {
  display: inline-block;
  width: 45%;
  height: 60px;
}

.division-line {
  text-align: center;
  display: inline-block;
  color: #999;
  width: 50px;
}

.clock {
  display: inline-block;
}

.upload-style {
  vertical-align: middle;
  display: inline-block;
  // width: 60px;
  // height: 60px;
  border: none;
}

.img-style {
  margin: auto;
  background-color: #eee;
  width: 90px;
  height: 60px;
  vertical-align: middle;
}

.avatar {
  width: 60px;
  height: 60px;
  display: block;
}

.line-style {
  background-color: #dfe2e8;
  height: 1px;
  // width: 80%;
  // margin: 0 auto;
  margin-bottom: 20px;
}
</style>
